

cc.Class({
    extends: cc.Component,

    properties: {
    },

    setInfo(target,lv){
        for(var i = 0;i<this.node.childrenCount;i++){
            this.node.getChildren()[i].active = i<lv
        }
        var self = this;
        this.scheduleOnce(function(){
            self.node.destroy();
        },0.4);

        this.node.angle = -this.lookAtObj(target)
   
    },

    lookAtObj(target){
        //计算出朝向
        var dx = target.x - this.node.x;
        var dy = target.y - this.node.y;
       
        var dir = cc.v2(dx,dy);
        //根据朝向计算出夹角弧度
        var angle = dir.signAngle(cc.v2(1,0));

        //将弧度转换为欧拉角
        var degree = angle / Math.PI * 180;
        //赋值给节点
        return degree;
    },


});
